|
|
|
|
|
|
|
'Move to the percent position specified
If fPct > 100 Then fPct = 100
If fPct < 0 Then fPct = 0
NewDyn.PercentPosition = fPct
'Move to the absolute position specified
If lAbs > rsTest.RecordCount Then lAbs = NewDyn.RecordCount
If lAbs < 0 Then lAbs = 0
NewDyn.AbsolutePosition = lAbs |
|
|
|
|
|
|
|
|
Using Filters, Indexes, and Sorts |
|
|
|
|
|
|
|
|
Filters, indexes, and sorts are properties of the recordset object. You can set these properties using an assignment statement such as this one: |
|
|
|
|
|
|
|
|
rsTest.Filter = "LastName = 'Smith'" |
|
|
|
|
|
|
|
|
Filters, indexes, and sorts enable you to control the scope of records being processed and the order in which records are processed. Filters (which are available only for dynasets and snapshots) limit the scope of records by specifying that they meet certain criteria, such as "last name starts with M." Indexes (available only for tables) and sorts (available only for dynasets and snapshots) specify the order of a recordset based on the value of one or more fields in the recordset. For sorts and indexes, you can also specify ascending or descending sort order. |
|
|
|
|
|
|
|
|
Setting the Filter Property |
|
|
|
|
|
|
|
|
The Filter property is available only for dynasets and snapshots. Although the following discussion refers only to dynasets, the same statements hold true for snapshots. When set, the Filter property does not affect the current dynaset, but filters records that are copied to a second dynaset or snapshot created from the first. |
|
|
|
|
|
|
|
|
You can specify the Filter property of a dynaset the same way you specify the Where clause of a SQL statement, but without the Where keyword. The filter can be a simple statement, such as State = 'TN', or one that uses multiple conditions, such as State = 'AR' AND Lastname = 'Smith'. You can also use an expression, such as Lastname LIKE 'S*', to find people whose last names begin with S. See the section "Setting Up a Dynaset" earlier in this chapter for an example of creating a new recordset by using the Filter property. |
|
|
|
|
|
|
|
|
You can include added flexibility in your Filter conditions by using functions in the condition. For example, if you want to filter a dynaset of all states with the second letter of the state code equal to L, use the Mid function, as shown here: |
|
|
|
|
|
|
|
|
rsTest.Filter = "Mid(State,2,1) = 'L'" |
|
|
|
|
|
|
|
|
Using functions does work, but it is an inefficient way to filter a dynaset. A better approach is to include the condition in the query used to create the dynaset in the first place. |
|
|
|
|
|